
// ajax的二次封装
function request(url, params, type = "get") {  // 向指定接口发送请求  返回一个Promise实例
    return new Promise(function (resolve, reject) {
        $.ajax({
            type: type,
            url: url,
            data: {
                ...params
            },
            dataType: "json",
            success: function (result) {
                resolve(result); //请求成功就返回数据 
            },
            error: function (err) {
                reject(err);    //请求失败 =>返回错误
            }
        })
    })
}
//parmas传入的数据
const isExistUser = (params = {}) => request("../php/isExistUser.php", params);
const isExistPhone = (params = {}) => request("../php/isExistPhone.php", params);
const isExistEmail = (params = {}) => request("../php/isExistEmail.php", params);
const register = (params = {}) => request("../php/register.php", params, "post");
const myadmin = (params = {}) => request("../php/admin.php", params, "post");
const login = (params = {}) => request("../php/login.php", params, "post");
const loginAccount = (params = {}) => request("../php/login_account.php", params, "post");
// const updateGradeById = (params = {}) => request("../php/updateGradeById.php", params, "post");
const searchAllGoods = (params = {}) => request("../php/searchAllGoods.php", params);
const searchAllGoodsLimit = (params = {}) => request("../php/searchAllGoodsLimit.php", params);
const goodDetail = (params = {}) => request("../php/goodDetail.php", params);//通过pid查找产品
const addToShoppingCar = (params = {}) => request("../php/addToShoppingCar.php", params, "post");
const addTolistcenter = (params = {}) => request("../php/addTolistcenter.php", params, "post");
const searchShoppingCarByUser = (params = {}) => request("../php/searchShoppingCarByUser.php", params, "post");
const deleteShopping=(params = {}) => request("../php/deleteShopping.php", params,"post");
const overShopping=(params = {}) => request("../php/overShopping.php", params,"post");